/*
 * Ant Group
 * Copyright (c) 2004-2024 All Rights Reserved.
 */
package com.alipay.zmdepositdemo.controller;

import com.alipay.zmdepositdemo.model.OpenResponse;
import com.alipay.zmdepositdemo.service.manage.DepositOrderManageService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 完结免押订单
 *
 * @author zhangjian
 * @version DepositOrderFinishController.java, v 0.1 2024年07月04日 14:32 zhangjian
 */

@Api(tags = "完结免押订单")
@ApiSupport(order = 7)
@RestController
@RequestMapping(value = "/finish-deposit-order")
public class DepositOrderFinishController {

    @Autowired
    private DepositOrderManageService depositOrderManageService;

    /**
     * 完结免押订单
     *
     * @see <a href="https://opendocs.alipay.com/open/77d39a7a_alipay.fund.auth.order.unfreeze?scene=common&pathHash=38132584">...</a>
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "完结免押订单接口")
    @GetMapping(value = "/finish")
    public OpenResponse<Boolean> finishOrder(
            @ApiParam(value = "支付宝资金授权订单号", defaultValue = "2014112611001004680073956707") @RequestParam(required = true)
            String authNo,
            // 如果是针对同一笔授权单不同的解冻请求，如第一次解冻1元，第二次解冻2元，则解冻请求流水号必须不重复；如果是针对同一笔解冻请求的多次发起，则需要保证每次发起，解冻请求流水号和解冻金额都相同
            @ApiParam(value = "解冻请求流水号", defaultValue = "outRequestNoHZ01RF001") @RequestParam(required = true) String outRequestNo,
            @ApiParam(value = "本次操作解冻的金额", defaultValue = "20.11") @RequestParam(required = true) String amount,
            @ApiParam(value = "本次解冻操作的附言描述", defaultValue = "014-05期解冻200.00元") @RequestParam(required = true) String remark,
            @ApiParam(value = "解冻扩展信息", defaultValue = "{\"unfreezeBizInfo\": \"{\\\"bizComplete\\\":\\\"true\\\"}\"}")
            @RequestParam(required = false) String extraParam) {
        return depositOrderManageService.finishOrder(authNo, outRequestNo, amount, remark, extraParam);
    }
}